//
//  NewsOverviewController.m
//  studip
//
//  Created by Christian Manteuffel on 05.07.10.
//  Copyright 2010 Fontys University of Applied Sciences. All rights reserved.
//

#import "NewsOverviewController.h"


@implementation NewsOverviewController

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (void)popToLauncherView
{
  [self.navigationController popToRootViewControllerAnimated:YES];
}

- (void)loadView
{
	[super loadView];
  
  [self.navigationItem setRightBarButtonItem:[[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"eingangsbildschirm"] style:UIBarButtonItemStyleBordered target:self action:@selector(popToLauncherView)] autorelease] animated:YES];
}

- (id)init {
	if (self = [super init]) {

		self.tableViewStyle = UITableViewStylePlain;
		self.variableHeightRows = YES;
		self.title = @"Neuigkeiten";
		
		NSMutableArray* items = [[NSMutableArray  alloc] init];
		NSMutableArray* sections = [[NSMutableArray  alloc] init];
		NSMutableArray* itemRows = [[NSMutableArray  alloc] init];
		
		
		[sections addObject:@"Designing user experiences"];
		[itemRows addObject:[TTTableSubtextItem
							 itemWithText: @"File added"
 							 caption: @"Slides/Session 01.pdf"
							 URL: @"fb://fileDetails/10"
							 accessoryURL: @"fb://fileDetails/10"]];	
		[itemRows addObject:[TTTableTextItem
							 itemWithText: @"Quickinfo changed"
							 URL: @"fb://courseDetails/1"
							 accessoryURL: @"fb://courseDetails/1"]];
		[items addObject: itemRows];
		
		TT_RELEASE_SAFELY(itemRows);
		itemRows = [[NSMutableArray  alloc] init];
		
		
		[sections addObject:@"Theoretische Informatik 2"];
		[itemRows addObject:[TTTableSubtextItem
							 itemWithText: @"New Forum post"
							 caption: @"Fragen zu Zettel4"
							 URL: @"fb://courseDetails/2"
							 accessoryURL: @"fb://courseDetails/2"]];
		[items addObject: itemRows];
		
		TT_RELEASE_SAFELY(itemRows);
		itemRows = [[NSMutableArray  alloc] init];
		
		
		[sections addObject:@"Informatik und Gesellschaft"];
		[itemRows addObject:[TTTableSubtextItem
							 itemWithText: @"New Wiki entry"
							 caption: @"Fachgesprächtermine"
							 URL: @"fb://courseDetails/3/wiki/1"
							 accessoryURL: @"fb://courseDetails/3/wiki/1"]];
		[itemRows addObject:[TTTableSubtextItem
							 itemWithText: @"New News"
							 caption: @"Seminar am 16.04.09"
							 URL: @"fb://courseDetails/3/news/1"
							 accessoryURL: @"fb://courseDetails/3/news1"]];
		[items addObject: itemRows];
		
		
		
		TTSectionedDataSource* ds = [[TTSectionedDataSource alloc] autorelease];
		ds.sections = sections;
		ds.items = items;
		self.dataSource = ds;
		
		TT_RELEASE_SAFELY(sections);
		TT_RELEASE_SAFELY(items);
	}
	
	return self;
}

- (void)dealloc {
	[super dealloc];
}

@end
